#include <iostream>
#include <string>
using namespace std;

void test_const()
{
	const int num = 5;
	int arr[num];

	for (int i = 0; i < num; i++)
	{
		arr[i] = i;
	}

	//虽然编译通过，但不会执行
	int *p = (int *)&num;
	*p = 67;
	cout << num << endl;

	//强制去掉const属性
	int *p2 = const_cast <int *>(&num);
	*p2 = 678; //可以编译通过,但不执行
	cout << num << endl;

	int a = 10;
	const int b = 34;
	int * const pa = &a;
	//int * const pb = &b; //编译报错(类型不匹配,左边是指针不能变,右边是地址中的内容不能变)
	*pa = 347;
	cout << a << endl;

	int const *pa1 = &a; // 左边是 指针指向的内容不能变
	//*pa1 = 234;编译报错,指针指向的内容不能变
	int const *pb1 = &b;
}

void main3()
{
	test_const();
	system("pause");
}